﻿using FluentNHibernate.Cfg;
using FluentNHibernate.Cfg.Db;
using NHibernate;
using HP.Cachalote.Repositories.NHibernate.DataMappings;

namespace HP.Cachalote.Repositories.NHibernate
{
    public static class FluentNHibernateHelper
    {
        /// <summary>
        /// Connect to data source and return the session.
        /// </summary>
        /// <returns>An instance that implements ISessionFactory.</returns>
        public static ISessionFactory CreateSessionFactory()
        {
            return Fluently.Configure()
                .Database(MsSqlCeConfiguration.Standard.ConnectionString(@"Data Source=..\..\DataSource\HP.Cachalote.Database.sdf;").ShowSql())
                .Mappings(m => m.FluentMappings.AddFromAssemblyOf<TodoLabelMap>())
                .BuildSessionFactory();

            //return Fluently.Configure()
            //    .Database(MsSqlConfiguration.MsSql2008.ConnectionString(c => c.FromConnectionStringWithKey("Todo")))
            //    .Mappings(m => m.FluentMappings.AddFromAssemblyOf<TodoLabelMap>())
            //    .BuildSessionFactory();
        }
    }
}
